/**
 * 
 */
package com.tvshows.front.listener.list;

import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;

import com.tvshows.front.listener.command.ModifyFavoriteCommand;
import com.tvshows.front.ui.favorite.ListCompositeFavoriteUI;
import com.tvshows.interactions.ObserverBdd;

/**
 * @author tMidy
 * <p>
 * Mouse listener implementation on favorite list
 * </p>
 */
public class ListListener
    implements MouseListener
{

    /**
     * The {@link ListCompositeFavoriteUI}
     */
    private final ListCompositeFavoriteUI listComposite;

    /**
     * Constructeur
     */
    public ListListener( ListCompositeFavoriteUI listComposite )
    {
        this.listComposite = listComposite;
    }

    /**
     * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
     */
    @Override
    public void mouseDoubleClick( MouseEvent e )
    {
        if ( !listComposite.getSelectedFavorite().equals( "NoSelection" ) )
        {
            /*
             * The command to execute
             */
            ModifyFavoriteCommand command = new ModifyFavoriteCommand( listComposite );
            command.executeCommand();
        }
    }

    /**
     * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
     */
    @Override
    public void mouseUp( MouseEvent e )
    {
        ObserverBdd.getObserverBdd().activeDeleteOnFavorite();
    }

    /**
     * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
     */
    @Override
    public void mouseDown( MouseEvent e )
    {

    }
}
